package com.livgo.service.impl;

import cn.hutool.core.lang.Snowflake;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.livgo.dao.po.SecretKey;
import com.livgo.mapper.SecretKeyMapper;
import com.livgo.service.SecretKeyService;
import org.springframework.stereotype.Service;

@Service
public class SecretKeyServiceImpl extends ServiceImpl<SecretKeyMapper, SecretKey> implements SecretKeyService {
    @Override
    public String genKey() {
        Snowflake snowflake = new Snowflake();

        String s = snowflake.nextIdStr();

        SecretKey secretKey = new SecretKey();

        secretKey.setId(s);

        secretKey.setSecretKey(s);

        this.save(secretKey);

        return s;
    }
}
